package no.ntnu.item.taxisystemgui.test;

import no.ntnu.item.arctis.runtime.IStateMachine;
import no.ntnu.item.arctis.runtime.Runtime;
import no.ntnu.item.arctis.runtime.Register;
import no.ntnu.item.arctis.runtime.IRegister;
import no.ntnu.item.arctis.runtime.Scheduler;

public class MyRuntime extends Runtime {

	private MyRuntime(IRegister register) {
		super(register);
	}

    public static Runtime create() {
        MyRuntime runtime = new MyRuntime(new Register());
        return runtime;
    }

	protected IStateMachine createDefaultStateMachine(Scheduler scheduler) {
		return new no.ntnu.item.taxisystemgui.test.component.ComponentSM(scheduler, null, null);
	}

	protected IStateMachine createSession(String signalID, Scheduler scheduler, String sessionID, String parentSessionID) {
        if("_c1_TaxiClient_init".equals(signalID)) {
            return new no.ntnu.item.taxisystemgui.test.component.TaxiClientSM(scheduler, sessionID, parentSessionID);
        } else if("_c0_UserClient_init".equals(signalID)) {
		    return new no.ntnu.item.taxisystemgui.test.component.UserClientSM(scheduler, sessionID, parentSessionID);
        }
        return null;
    }

	protected boolean createsSession(String signalID) {
        if("_c1_TaxiClient_init".equals(signalID)) {
            return true;
        } else if("_c0_UserClient_init".equals(signalID)) {
            return true;
        }
        return false;
    }

}
